package com.shakespace.artofandroid.chapter06drawable

import android.graphics.drawable.TransitionDrawable
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import com.shakespace.artofandroid.R
import kotlinx.android.synthetic.main.activity_drawable.*

class DrawableActivity : AppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_drawable)


        level.setOnClickListener {
            val index = level.drawable.level
            if (level.drawable.level < 6) {
                level.setImageLevel(index + 1)
            } else {
                level.setImageLevel(0)
            }
        }

        transition.setOnClickListener {
            (transition.drawable as TransitionDrawable).startTransition(2000)
//            (transition.drawable as TransitionDrawable).reverseTransition(2000)
        }

        scale.setImageLevel(2)

        scale.setOnClickListener {
            scale.setImageLevel(7000)
        }

        clip.setImageLevel(3000)
        clip.setOnClickListener {
            clip.setImageLevel(8000)
        }

    }
}
